{$CLEO .cs}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "PlneInt"

// By ArtemQa146

const
    plane_obj = 31@
    actor_PL = 30@
    seat_1 = 29@
    seat_2 = 28@
    seat_3 = 27@
    seat_4 = 26@
    head_1 = 25@
    head_2 = 24@
    head_3 = 23@
    head_4 = 22@
    actor_2 = 21@
    actor_3 = 20@
    pilot_1 = 19@
    seat_5 = 18@
    seat_6 = 17@
    head_5 = 16@
    head_6 = 15@
    pilot_2 = 14@
    step = 13@
    CREATED = 12@
    CAMERA_MODE = 11@
end

while true
wait 1000
    if
        player.Defined(0)
    then
        if
            00DF:   actor $PLAYER_ACTOR driving
        then
            03C0: 1@ = actor $PLAYER_ACTOR car
            if
                0137:   car 1@ model == 577
            then
                0AAA: 0@ = get_script_struct_named "PLANES"
                if
                    not 0@ == 0
                then
                    CREATED = false
                    CAMERA_MODE = 1
                    timera = 0
                    
                    repeat
                    wait 0
                        //0AD1: show_formatted_text_highpriority "%d %d %d %d %d" time 2000 $9503 timera $9508 $9522 $9512
                        //0AD1: show_formatted_text_highpriority "%d" time 2000 CAMERA_MODE
                        
                        0AAA: 0@ = get_script_struct_named "PLANES"
                        if
                            not 0@ == 0
                        then
                        
                            if
                                $9503 == 0
                            then
                                timera = 0
                            end
                            
                            if and
                                timera > 16000
                                $9503 == 1
                                $9508 == 0
                                not $9522 == 2
                            then
                                if
                                    056E:   car $9479 defined
                                then
                                    if
                                        00DB:   actor $PLAYER_ACTOR in_car $9479
                                    then
                                        if
                                            model.Available(0)
                                        then
                                        
                                            if
                                                CREATED == false
                                            then
                                                gosub @Create
                                            else
                                                gosub @Put
                                            end
                                            
                                            CREATED = true
                                            
                                            wait 500
                                            
                                            if
                                                CAMERA_MODE >= 5
                                            then
                                                CAMERA_MODE = 1
                                            end

                                            if
                                                CAMERA_MODE == 1
                                            then
                                                gosub @camera_1
                                            end
                                            
                                            if
                                                CAMERA_MODE == 2
                                            then
                                                gosub @camera_3
                                            end
                                            
                                            if
                                                CAMERA_MODE == 3
                                            then
                                                gosub @camera_2
                                            end
                                            
                                            if
                                                CAMERA_MODE == 4
                                            then
                                                gosub @camera_5
                                            end

                                            timera = 0
                                            step = 0
                                            
                                            052C: set_player $PLAYER_CHAR drunk_visuals 25
                                            
                                            wait 0
                                            093D: lock_camera_on_cinematic_view 0

                                            repeat
                                            wait 0
                                                0AAA: 0@ = get_script_struct_named "PLANES"
                                                if or
                                                    00E1:   player 0 pressed_key 16
                                                    0@ == 0
                                                    856E:   not car $9479 defined
                                                    80DF:   not actor $PLAYER_ACTOR driving
                                                then
                                                    break
                                                end
                                                
                                                if
                                                    $9522 == 1
                                                then
                                                    if
                                                        00E1:   player 0 pressed_key 15
                                                    then
                                                        break
                                                    end
                                                end

                                                if and
                                                    step == 0
                                                    timera > 4000
                                                then
                                                    step = 1
                                                end
                                                
                                                if
                                                    CAMERA_MODE == 1
                                                then
                                                    if
                                                        step == 0
                                                    then
                                                        gosub @camera_1
                                                    end

                                                    if
                                                        step == 1
                                                    then
                                                        gosub @camera_2
                                                    end

                                                    if and
                                                        step == 1
                                                        timera > 8000
                                                    then
                                                        step = 2
                                                    end

                                                    if
                                                        step == 2
                                                    then
                                                        gosub @camera_3
                                                    end
                                                end
                                                
                                                if
                                                    CAMERA_MODE == 2
                                                then
                                                    if
                                                        step == 0
                                                    then
                                                        gosub @camera_3
                                                    end

                                                    if
                                                        step == 1
                                                    then
                                                        gosub @camera_4
                                                    end

                                                    if and
                                                        step == 1
                                                        timera > 8000
                                                    then
                                                        step = 2
                                                    end

                                                    if
                                                        step == 2
                                                    then
                                                        gosub @camera_2
                                                    end
                                                end
                                                
                                                if
                                                    CAMERA_MODE == 3
                                                then
                                                    if
                                                        step == 0
                                                    then
                                                        gosub @camera_4
                                                    end

                                                    if
                                                        step == 1
                                                    then
                                                        gosub @camera_3
                                                    end

                                                    if and
                                                        step == 1
                                                        timera > 8000
                                                    then
                                                        step = 2
                                                    end

                                                    if
                                                        step == 2
                                                    then
                                                        gosub @camera_1
                                                    end
                                                end
                                                
                                                if
                                                    CAMERA_MODE == 4
                                                then
                                                    if
                                                        step == 0
                                                    then
                                                        gosub @camera_5
                                                    end

                                                    if
                                                        step == 1
                                                    then
                                                        gosub @camera_1
                                                    end

                                                    if and
                                                        step == 1
                                                        timera > 8000
                                                    then
                                                        step = 2
                                                    end

                                                    if
                                                        step == 2
                                                    then
                                                        gosub @camera_4
                                                    end
                                                end
                                                
                                            until timera > 12000
                                            
                                            CAMERA_MODE += 1
                                            
                                            timera = 0
                                            
                                            052C: set_player $PLAYER_CHAR drunk_visuals 0

                                            02EB: restore_camera_with_jumpcut
                                            
                                            093D: lock_camera_on_cinematic_view 1
                                        end
                                    end
                                else
                                    break
                                end
                            end
                        else
                            break
                        end
                    until not player.Defined(0)
                    
                    if
                        CREATED == true
                    then
                        if 03CA:   object plane_obj exists
                        then 0108: destroy_object plane_obj
                        end
                        if 03CA:   object seat_1 exists
                        then 0108: destroy_object seat_1
                        end
                        if 03CA:   object seat_2 exists
                        then 0108: destroy_object seat_2
                        end
                        if 03CA:   object seat_3 exists
                        then 0108: destroy_object seat_3
                        end
                        if 03CA:   object seat_4 exists
                        then 0108: destroy_object seat_4
                        end
                        if 03CA:   object seat_5 exists
                        then 0108: destroy_object seat_5
                        end
                        if 03CA:   object seat_6 exists
                        then 0108: destroy_object seat_6
                        end
                        if 03CA:   object head_1 exists
                        then 0108: destroy_object head_1
                        end
                        if 03CA:   object head_2 exists
                        then 0108: destroy_object head_2
                        end
                        if 03CA:   object head_3 exists
                        then 0108: destroy_object head_3
                        end
                        if 03CA:   object head_4 exists
                        then 0108: destroy_object head_4
                        end
                        if 03CA:   object head_5 exists
                        then 0108: destroy_object head_5
                        end
                        if 03CA:   object head_6 exists
                        then 0108: destroy_object head_6
                        end
                        if 056D:   actor actor_PL defined
                        then 009B: destroy_actor actor_PL
                        end
                        if 056D:   actor actor_2 defined
                        then 009B: destroy_actor actor_2
                        end
                        if 056D:   actor actor_3 defined
                        then 009B: destroy_actor actor_3
                        end
                        if 056D:   actor pilot_1 defined
                        then 009B: destroy_actor pilot_1
                        end
                        if 056D:   actor pilot_2 defined
                        then 009B: destroy_actor pilot_2
                        end
                    end
                end
            end
        end
    end
end


:Camera_1
if and
    056D:   actor actor_PL defined
    056D:   actor actor_2 defined
then
    04C4: store_coords_to 1@ 2@ 3@ from_actor actor_PL with_offset 1.8 0.9 0.0
    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
    04C4: store_coords_to 1@ 2@ 3@ from_actor actor_2 with_offset -0.2 -0.55 -0.15
    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
end
return

:Camera_2
if
    056D:   actor pilot_1 defined
then
    04C4: store_coords_to 1@ 2@ 3@ from_actor pilot_1 with_offset 2.8 0.1 0.2
    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
    04C4: store_coords_to 1@ 2@ 3@ from_actor pilot_1 with_offset 0.0 -0.9 -0.4
    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
end
return

:Camera_3
if
    056D:   actor actor_PL defined
then
    04C4: store_coords_to 1@ 2@ 3@ from_actor actor_PL with_offset 0.8 0.4 -0.1
    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
    04C4: store_coords_to 1@ 2@ 3@ from_actor actor_PL with_offset 0.0 -0.3 0.0
    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
end
return

:Camera_4
if
    056D:   actor actor_PL defined
then
    04C4: store_coords_to 1@ 2@ 3@ from_actor actor_PL with_offset 0.0 1.0 -0.4
    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
    04C4: store_coords_to 1@ 2@ 3@ from_actor actor_PL with_offset 0.0 -0.0 -0.2
    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
end
return

:Camera_5
if
    056D:   actor pilot_2 defined
then
    04C4: store_coords_to 1@ 2@ 3@ from_actor pilot_2 with_offset -2.6 -1.82 -0.2
    015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
    04C4: store_coords_to 1@ 2@ 3@ from_actor pilot_2 with_offset 0.0 0.3 0.2
    0160: set_camera_point_at 1@ 2@ 3@ switchstyle 2
end
return

:Create
repeat
wait 0
04ED: load_animation  "IntPlane"
until 04EE:   animation "IntPlane" loaded

04C4: store_coords_to 1@ 2@ 3@ from_actor $player_actor with_offset 0.0 -30.0 200.0
model.Load(14404)
model.Load(1563)
model.Load(1562)
model.Load(17)
model.Load(46)
model.Load(61)
model.Load(1897)
038B: load_requested_models
0E01: create_object_no_save 14404 at 1@ 2@ 3@ offset 0 ground 0 to plane_obj

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -1.264 -3.383 -1.123
0E01: create_object_no_save 1562 at 1@ 2@ 3@ offset 0 ground 0 to seat_1
0177: set_object seat_1 Z_angle_to 180.0
0382: set_object seat_1 collision_detection 0

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.448 -3.383 -1.123
0E01: create_object_no_save 1562 at 1@ 2@ 3@ offset 0 ground 0 to seat_2
0177: set_object seat_2 Z_angle_to 180.0
0382: set_object seat_2 collision_detection 0

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -1.164 -4.852 -1.123
0E01: create_object_no_save 1562 at 1@ 2@ 3@ offset 0 ground 0 to seat_3
0177: set_object seat_3 Z_angle_to 180.0
0382: set_object seat_3 collision_detection 0

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.448 -5.052 -1.123
0E01: create_object_no_save 1562 at 1@ 2@ 3@ offset 0 ground 0 to seat_4
0177: set_object seat_4 Z_angle_to 180.0
0382: set_object seat_4 collision_detection 0

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.76 5.236 -0.623
0E01: create_object_no_save 1562 at 1@ 2@ 3@ offset 0 ground 0 to seat_5
0177: set_object seat_5 Z_angle_to 180.0
0382: set_object seat_5 collision_detection 0

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset 0.76 5.236 -0.623
0E01: create_object_no_save 1562 at 1@ 2@ 3@ offset 0 ground 0 to seat_6
0177: set_object seat_6 Z_angle_to 180.0
0382: set_object seat_6 collision_detection 0


0400: store_coords_to 1@ 2@ 3@ from_object seat_1 with_offset 0.0 0.342 0.548
0E01: create_object_no_save 1563 at 1@ 2@ 3@ offset 0 ground 0 to head_1
0177: set_object head_1 Z_angle_to 180.0
0382: set_object head_1 collision_detection 0

0400: store_coords_to 1@ 2@ 3@ from_object seat_2 with_offset 0.0 0.342 0.548
0E01: create_object_no_save 1563 at 1@ 2@ 3@ offset 0 ground 0 to head_2
0177: set_object head_2 Z_angle_to 180.0
0382: set_object head_2 collision_detection 0

0400: store_coords_to 1@ 2@ 3@ from_object seat_3 with_offset 0.0 0.342 0.548
0E01: create_object_no_save 1563 at 1@ 2@ 3@ offset 0 ground 0 to head_3
0177: set_object head_3 Z_angle_to 180.0
0382: set_object head_3 collision_detection 0

0400: store_coords_to 1@ 2@ 3@ from_object seat_4 with_offset 0.0 0.342 0.548
0E01: create_object_no_save 1563 at 1@ 2@ 3@ offset 0 ground 0 to head_4
0177: set_object head_4 Z_angle_to 180.0
0382: set_object head_4 collision_detection 0

0400: store_coords_to 1@ 2@ 3@ from_object seat_5 with_offset 0.0 0.342 0.548
0E01: create_object_no_save 1563 at 1@ 2@ 3@ offset 0 ground 0 to head_5
0177: set_object head_5 Z_angle_to 180.0
0382: set_object head_5 collision_detection 0

0400: store_coords_to 1@ 2@ 3@ from_object seat_6 with_offset 0.0 0.342 0.548
0E01: create_object_no_save 1563 at 1@ 2@ 3@ offset 0 ground 0 to head_6
0177: set_object head_6 Z_angle_to 180.0
0382: set_object head_6 collision_detection 0


0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -1.2 -2.867 -1.661
009A: actor_PL = create_actor_pedtype 4 model 0 at 1@ 2@ 3@
0E24: fix_char actor_PL ground 0 brightness 1 and_fade_in 0
0575: set_actor actor_PL pinned_position 1
02AB: set_actor actor_PL immunities BP 1 FP 1 EP 1 CP 1 MP 1
0812: AS_actor actor_PL perform_animation "Seat_pl_3" IFP "IntPlane" framedelta 10000.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB


0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.43 -2.767 -1.661
0376: actor_2 = create_random_actor_at 1@ 2@ 3@
0E24: fix_char actor_2 ground 0 brightness 1 and_fade_in 0
0575: set_actor actor_2 pinned_position 1
02AB: set_actor actor_2 immunities BP 1 FP 1 EP 1 CP 1 MP 1
0812: AS_actor actor_2 perform_animation "Seat_pl_1" IFP "IntPlane" framedelta 10000.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.43 -4.267 -1.661
0376: actor_3 = create_random_actor_at 1@ 2@ 3@
0E24: fix_char actor_3 ground 0 brightness 1 and_fade_in 0
0575: set_actor actor_3 pinned_position 1
02AB: set_actor actor_3 immunities BP 1 FP 1 EP 1 CP 1 MP 1
0812: AS_actor actor_3 perform_animation "Seat_pl_1" IFP "IntPlane" framedelta 10000.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.837 5.734 -1.161
009A: pilot_1  = create_actor_pedtype 4 model 61 at 1@ 2@ 3@
0E24: fix_char pilot_1 ground 0 brightness 1 and_fade_in 0
0575: set_actor pilot_1 pinned_position 1
02AB: set_actor pilot_1 immunities BP 1 FP 1 EP 1 CP 1 MP 1
0812: AS_actor pilot_1 perform_animation "Seat_pl_2" IFP "IntPlane" framedelta 10000.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB

0E2E: create_render_object_to_char_bone pilot_1 model 1897 bone 34 offset 0.33 0.1 0.05 rotation 0 70.0 0 store_to 1@
0E37: set_render_object_scale 1@ 0.3 0.3 0.3

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset 0.737 5.734 -1.161
009A: pilot_2  = create_actor_pedtype 4 model 61 at 1@ 2@ 3@
0E24: fix_char pilot_2 ground 0 brightness 1 and_fade_in 0
0575: set_actor pilot_2 pinned_position 1
02AB: set_actor pilot_2 immunities BP 1 FP 1 EP 1 CP 1 MP 1
0812: AS_actor pilot_2 perform_animation "Seat_pl_4" IFP "IntPlane" framedelta 10000.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB

model.Destroy(14404)
model.Destroy(1563)
model.Destroy(1562)
model.Destroy(61)
model.Destroy(1897)

04EF: release_animation "IntPlane"
return


:Put
04C4: store_coords_to 1@ 2@ 3@ from_actor $player_actor with_offset 0.0 -30.0 200.0
01BC: put_object plane_obj at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -1.264 -3.383 -1.123
01BC: put_object seat_1 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.448 -3.383 -1.123
01BC: put_object seat_2 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -1.164 -4.852 -1.123
01BC: put_object seat_3 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.448 -5.052 -1.123
01BC: put_object seat_4 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.76 5.236 -0.623
01BC: put_object seat_5 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset 0.76 5.236 -0.623
01BC: put_object seat_6 at 1@ 2@ 3@


0400: store_coords_to 1@ 2@ 3@ from_object seat_1 with_offset 0.0 0.342 0.548
01BC: put_object head_1 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object seat_2 with_offset 0.0 0.342 0.548
01BC: put_object head_2 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object seat_3 with_offset 0.0 0.342 0.548
01BC: put_object head_3 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object seat_4 with_offset 0.0 0.342 0.548
01BC: put_object head_4 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object seat_5 with_offset 0.0 0.342 0.548
01BC: put_object head_5 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object seat_6 with_offset 0.0 0.342 0.548
01BC: put_object head_6 at 1@ 2@ 3@


0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -1.2 -2.867 -1.661
00A1: put_actor actor_PL at 1@ 2@ 3@


0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.43 -2.767 -1.661
00A1: put_actor actor_2 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.43 -4.267 -1.661
00A1: put_actor actor_3 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset -0.837 5.734 -1.161
00A1: put_actor pilot_1 at 1@ 2@ 3@

0400: store_coords_to 1@ 2@ 3@ from_object plane_obj with_offset 0.737 5.734 -1.161
00A1: put_actor pilot_2 at 1@ 2@ 3@

return